package com.example.g5project.chat.model.enumeration;

import com.example.g5project.chat.constant.ImBaseConstant;
import java.util.Objects;
import java.util.stream.Stream;
import lombok.Getter;

@Getter
public enum MessageTypeEnum {

    TIMTextElem(1, "文本消息", ImBaseConstant.TIM_TEXT_ELEM),
    TIMLocationElem(2, "位置消息", ImBaseConstant.TIM_LOCATION_ELEM),
    TIMFaceElem(3, "表情消息", ImBaseConstant.TIM_FACE_ELEM),
    TIMCustomElem(4, "自定义消息", ImBaseConstant.TIM_CUSTOM_ELEM),
    TIMSoundElem(5, "语音消息", ImBaseConstant.TIM_SOUND_ELEM),
    TIMImageElem(6, "图像消息", ImBaseConstant.TIM_IMAGE_ELEM),
    TIMFileElem(7, "文件消息", ImBaseConstant.TIM_FILE_ELEM),
    TIMVideoFileElem(8, "视频消息", ImBaseConstant.TIM_VIDEOFILE_ELEM),

    ;


    private Integer id;
    private String desc;
    private String imMessageType;

    MessageTypeEnum(int id, String desc, String imMessageType) {
        this.id = id;
        this.desc = desc;
        this.imMessageType = imMessageType;
    }

    public static MessageTypeEnum parseById(Integer id) {
        return Stream.of(MessageTypeEnum.values()).filter(e -> Objects.equals(e.getId(), id)).findAny()
            .orElseThrow(() -> new IllegalArgumentException("消息类型不正确"));
    }
}
